fn = taptype = None
if uname.find(":") != -1:
(typ, fn) = uname.split(":", 1)
- if typ in ("phy", "drbd") and not fn.startswith("/"):
+
+ if typ == "phy" and not fn.startswith("/"):
fn = "/dev/%s" %(fn,)
+
+ if typ == "drbd":
+ if not fn.startswith("drbd"):
+ (drbdadmstdin, drbdadmstdout) = os.popen2(["/sbin/drbdadm", "sh-dev", fn])
+ fn = drbdadmstdout.readline().strip()
+ else:
+ fn = "/dev/%s" %(fn,)
+
if typ == "tap":
(taptype, fn) = fn.split(":", 1)
return (fn, taptype)
disk = devinfo[1]['uname']
fn = blkdev_uname_to_file(disk)
+
+ # If this is a drbd volume, check if we need to activate it
+ if disktype.find(":") != -1:
+ (disktype, diskname) = disk.split(':', 1)
+ if disktype == 'drbd':
+ (drbdadmstdin, drbdadmstdout) = os.popen2(["/sbin/drbdadm", "state", diskname])
+ (state, junk) = drbdadmstdout.readline().split('/', 1)
+ if state == 'Secondary':
+ os.system('/sbin/drbdadm primary ' + diskname)
+
taptype = blkdev_uname_to_taptype(disk)
mounted = devtype in ['tap', 'tap2'] and taptype != 'aio' and taptype != 'sync' and not os.stat(fn).st_rdev
if mounted: